package hjt.com.componentbase.service;

import hjt.com.componentbase.service.empty_service.EmptyDesignService;
import hjt.com.componentbase.service.empty_service.EmptyLoginService;

public class ServiceFactory {

    private ILoginService mILogin;
    private IDesignService mIDesign;

    /**
     * 静止外部创建LoginService对象
     */
    private ServiceFactory() {
    }

    /**
     * 通过静态内部类实现LoginService单例
     */
    private static class Inner {
        private static ServiceFactory loginService = new ServiceFactory();
    }

    public static ServiceFactory getInstance() {
        return Inner.loginService;
    }

    /**
     * 接收user组件的Ilogin实例
     *
     * @param iLogin
     */
    public void setLoginService(ILoginService iLogin) {
        mILogin = iLogin;
    }

    /**
     * 返回user组件ILogin实例
     *
     * @return
     */
    public ILoginService getLoginService() {
        if (mILogin == null) {
            mILogin = new EmptyLoginService();
        }
        return mILogin;
    }

    public void setDesignService(IDesignService designService) {
        mIDesign = designService;
    }

    public IDesignService getDesignService() {
        if (mIDesign == null) {
            mIDesign = new EmptyDesignService();
        }
        return mIDesign;
    }

}
